package xyz.scootaloo.oj.offer;

import java.util.Arrays;

/**
 * @author flutterdash@qq.com
 * @since 2021/3/30 14:41
 */
public class P40a {

    public int[] getLeastNumbers(int[] arr, int k) {
        Arrays.sort(arr);
        int[] res = new int[k];
        if (k >= 0)
            System.arraycopy(arr, 0, res, 0, k);
        return res;
    }

    public static void main(String[] args) {
        int[] arr = {3, 2, 1};
        System.out.println(Arrays.toString(new P40a().getLeastNumbers(arr, 2)));
    }

}
